<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />

  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>We Want Pictures! &mdash; Zapmenot 0.1 documentation</title>
      <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
      <link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
  <!--[if lt IE 9]>
    <script src="_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
        <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
        <script src="_static/jquery.js"></script>
        <script src="_static/underscore.js"></script>
        <script src="_static/_sphinx_javascript_frameworks_compat.js"></script>
        <script src="_static/doctools.js"></script>
        <script src="_static/sphinx_highlight.js"></script>
    <script src="_static/js/theme.js"></script>
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="Theory and Methods" href="theory-and-methods.html" />
    <link rel="prev" title="Generating Results" href="results.html" /> 
</head>

<body class="wy-body-for-nav"> 
  <div class="wy-grid-for-nav">
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
            <a href="index.html" class="icon icon-home"> Zapmenot
          </a>
              <div class="version">
                0.1
              </div>
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>
        </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="license.html">Licence &amp; Disclaimer</a></li>
<li class="toctree-l1"><a class="reference internal" href="getting-started.html">Getting Started</a></li>
<li class="toctree-l1"><a class="reference internal" href="materials.html">Material Library</a></li>
<li class="toctree-l1"><a class="reference internal" href="isotopes.html">Isotope Library</a></li>
<li class="toctree-l1"><a class="reference internal" href="modeling.html">Modeling in ZapMeNot</a></li>
<li class="toctree-l1"><a class="reference internal" href="results.html">Generating Results</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">We Want Pictures!</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#graphics-from-a-zapmenot-python-script">Graphics from a ZapMeNot Python Script</a></li>
<li class="toctree-l2"><a class="reference internal" href="#graphics-in-a-jupyterlab-notebook">Graphics in a JupyterLab Notebook</a></li>
<li class="toctree-l2"><a class="reference internal" href="#going-headless-for-fun-and-profit">Going Headless For Fun and Profit</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="theory-and-methods.html">Theory and Methods</a></li>
<li class="toctree-l1"><a class="reference internal" href="benchmarks.html">Benchmarking</a></li>
<li class="toctree-l1"><a class="reference internal" href="module-docs.html">Module Contents</a></li>
<li class="toctree-l1"><a class="reference internal" href="developer.html">Developer</a></li>
<li class="toctree-l1"><a class="reference internal" href="version-history.html">Version History</a></li>
</ul>

        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="index.html">Zapmenot</a>
      </nav>

      <div class="wy-nav-content">
        <div class="rst-content">
          <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="index.html" class="icon icon-home"></a></li>
      <li class="breadcrumb-item active">We Want Pictures!</li>
      <li class="wy-breadcrumbs-aside">
            <a href="_sources/graphics.rst.txt" rel="nofollow"> View page source</a>
      </li>
  </ul>
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
             
  <section id="we-want-pictures">
<h1>We Want Pictures!<a class="headerlink" href="#we-want-pictures" title="Permalink to this heading"></a></h1>
<p>Checking a model geometry can be challenging.  To make the process a little easier
the ZapMeNot library includes the ability to display an interactive view of
the geometry, include source, shields, and detector.  The <a class="reference external" href="https://docs.pyvista.org">Pyvista</a> package is
required to support graphics.</p>
<section id="graphics-from-a-zapmenot-python-script">
<h2>Graphics from a ZapMeNot Python Script<a class="headerlink" href="#graphics-from-a-zapmenot-python-script" title="Permalink to this heading"></a></h2>
<p>Once you have a model built and populated with a source, detector, and (optionally)
shields, the following command can be used to display the model:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># display a model</span>
<span class="n">myModel</span><span class="o">.</span><span class="n">display</span><span class="p">()</span>
</pre></div>
</div>
<p>Provided you are using a an operating system with graphics capability (i.e. not just a console)
ZapMeNot will display something similar to the following graphic.  In this example the source
is a point source shown in red, the detector is shown in yellow, and two shields are shown
in blue.</p>
<img alt="_images/display.png" src="_images/display.png" />
<p>The display can be rotated, moved, zoomed, and more by using a mouse or <a class="reference external" href="https://docs.pyvista.org/api/plotting/plotting.html">keyboard shortcuts</a>.</p>
</section>
<section id="graphics-in-a-jupyterlab-notebook">
<h2>Graphics in a JupyterLab Notebook<a class="headerlink" href="#graphics-in-a-jupyterlab-notebook" title="Permalink to this heading"></a></h2>
<p>A convenient way to document a ZapMeNot analysis is to use a <a class="reference external" href="https://jupyter.org">JupyterLab notebook</a>.
Jupyterlab introduces just one additional wrinkle - optionally selecting a <a class="reference external" href="https://docs.pyvista.org/user-guide/jupyter/index.html">graphics backend</a>
for displaying graphics.  The <cite>panel</cite> backend tends to be compatible with the
ZapMeNot feature set.</p>
<p>Here’s a screenshot of a JupyterLab notebook.  Your display may look different, depending
on your workstation configuration.</p>
<img alt="_images/jupyterlab.png" src="_images/jupyterlab.png" />
</section>
<section id="going-headless-for-fun-and-profit">
<h2>Going Headless For Fun and Profit<a class="headerlink" href="#going-headless-for-fun-and-profit" title="Permalink to this heading"></a></h2>
<p>It is possible to display the model on a headless linux server (one with no graphics card)
by building your ZapMeNot model in a <a class="reference external" href="https://jupyter.org">JupyterLab notebook</a>.  Beyond selecting a suitable
backend, it’s also usually necessary to use <a class="reference external" href="https://www.x.org/releases/X11R7.6/doc/man/man1/Xvfb.1.xhtml">xvfb</a>.  This requires a couple of steps, so follow along!</p>
<p>First, it’s necessary to ensure that xvfb has been installed.  Here’s the command for Ubuntu (your system may be different):</p>
<p><code class="code docutils literal notranslate"><span class="pre">sudo</span> <span class="pre">apt</span> <span class="pre">install</span> <span class="pre">libgl1-mesa-glx</span> <span class="pre">xvfb</span></code></p>
<p>Next, add the following lines after the other import statements at the beginning of your JupyterLab notebook:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">pyvista.utilities</span> <span class="kn">import</span> <span class="n">xvfb</span>
<span class="n">xvfb</span><span class="o">.</span><span class="n">start_xvfb</span><span class="p">()</span>
<span class="n">pyvista</span><span class="o">.</span><span class="n">set_jupyter_backend</span><span class="p">(</span><span class="s1">&#39;panel&#39;</span><span class="p">)</span>
</pre></div>
</div>
</section>
</section>


           </div>
          </div>
          <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
        <a href="results.html" class="btn btn-neutral float-left" title="Generating Results" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
        <a href="theory-and-methods.html" class="btn btn-neutral float-right" title="Theory and Methods" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>&#169; Copyright 2019 - 2023, Alan Ford..
      <span class="lastupdated">Last updated on Feb 12, 2023.
      </span></p>
  </div>

  Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
    <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
    provided by <a href="https://readthedocs.org">Read the Docs</a>.
   

</footer>
        </div>
      </div>
    </section>
  </div>
  <script>
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script> 

</body>
</html>